package com.crm.jpaandthymeleaf.config;

import com.crm.jpaandthymeleaf.web.interceptor.AuthorizationInterceptor;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 周敬
 * @version 1.0
 * @packageName com.crm.jpaandthymeleaf.config
 * @fileName InterceptorConfig
 * @createTime 2021/12/17-16:37-星期五
 * @lastModify 2021/12/17-16:37-星期五
 */
//@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    String[] excludePathPatterns;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截路径规则
        String[] pathPatterns = {"/**"};
        //排除路径
        String[] excludPathPatterns = {"/","/login","/doLogin","/css/**","/fonts/**","/images/**","/js/**","/localcss/**"};
        registry.addInterceptor(new AuthorizationInterceptor())
                .addPathPatterns(pathPatterns)                //添加路径规则
                .excludePathPatterns(excludPathPatterns);     //添加排除路径
    }
}
